package com.mingqi.enetconnected.view.Dialog.single;


import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.mingqi.enetconnected.R;
import com.mingqi.enetconnected.util.resource.ResourceUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by li on 2018/8/31.
 * WeChat 18571658038
 * author LiWei
 */

public class SinglePickerHintAdapter extends BaseAdapter {


    private List<TimeValue> mData;

    public SinglePickerHintAdapter(List<TimeValue> data) {
        if (data == null) {
            data = new ArrayList<>();
        }
        mData = data;
    }



    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        MySingleHolder singleHolder = null;
        if (convertView == null) {

            convertView = ResourceUtils.getViewFollowParent(R.layout.item_single_choose_with_hint, parent);
            singleHolder = new MySingleHolder();
            singleHolder.cbSingle = convertView.findViewById(R.id.cb_single);
            singleHolder.textView=convertView.findViewById(R.id.note);
            convertView.setTag(singleHolder);

        } else {

            singleHolder = (MySingleHolder) convertView.getTag();
        }

        singleHolder.cbSingle.setText(mData.get(position).getValue());
        singleHolder.textView.setText(mData.get(position).getEmpValue());
        return convertView;
    }

    public void refresh(List<TimeValue> data) {
        if (data == null) {
            data = new ArrayList<>();
        }
        mData = data;
        notifyDataSetChanged();
    }


    static class MySingleHolder {

        CheckBox cbSingle;
        TextView textView;
    }
}
